<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">

<head>
    <th:block th:include="common/common_head :: commonHeader('采购申请头文件')"/>
    <link rel="stylesheet" th:href="@{/static/js/plugins/jquery-layout/jquery.layout-latest.css}">
    <!-- <style type="text/css">.table {table-layout:fixed;}</style> -->
</head>

<body class="gray-bg">

<div class="container-div ui-layout-center">
    <div class="row">
        <div class="col-sm-12 search-condition">
            <form id="materialSummaryForm" th:action="@{/materialSummary/list}" class="form-inline">
                <div class="select-list">
                    <ul>
                        <li class="col-sm-3" style="width: 33%">
                            <label>创建日期(起)：</label>
                            <input type="text" name="beginDate" id="beginDate" autocomplete="off"/>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <label>创建日期(止)：</label>
                            <input type="text" name="endDate" id="endDate" autocomplete="off"/>
                        </li>

                        <li class="col-sm-3" style="width: 33%">
                            <label>查询条件：</label>
                            <select id="goodsStatus" name="conditions">
                                <option value="ordertotalPrice">订单总价值</option>
                                <option value="orderTotalNumber">订单总数量</option>
                            </select>
                        </li>
                        <li class="col-sm-3" style="width: 33%">
                            <button id="materialSummarySearchBtn" type="button"
                                    class="btn btn-primary btn-rounded btn-sm"><i class="fa fa-search"></i>&nbsp;搜索
                            </button>
                            <button class="btn btn-warning btn-rounded btn-sm" type="reset"><i class="fa fa-eraser"></i>&nbsp;重置
                            </button>
                            <button id="materialSummaryAdvancedSearch" type="button"
                                    class="btn btn-primary btn-rounded btn-sm" style="display: none"><i
                                    class="fa fa-caret-down"></i>&nbsp;高级搜索
                            </button>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="col-sm-12 search-condition titleInfoBar" id="titleInfoBar">
            <span></span>
            <div class="titleInfoBarCloseBtn" title="关闭" onclick="closeTitleInfoBar(this)">&times;</div>
        </div>

        <div class="col-sm-12 select-info order-table">
            <div class="btn-group hidden-xs toolbar" id="materialSummaryToolBar" role="group">
                <a class="btn btn-outline btn-success btn-rounded" onclick="Export()">
                    <i class="fa fa-edit"></i> 导出Excel
                </a>
            </div>
            <div style="overflow:auto;">
                <table id="materialSummary" data-mobile-responsive="true" lay-filter="materialSummary"></table>
            </div>
        </div>
    </div>
</div>


<!--引入公共js-->
<div th:include="common/onload_js :: onloadJS"></div>
<script type="text/javascript" th:src="@{/static/js/plugins/jquery-layout/jquery.layout-latest.js}"></script>

<!-- Page-Level Scripts -->

<script type="text/javascript">
    var itemBS = Searcher.createBS('#materialSummary',
        [
            {checkbox: true},
            {field: 'rowNo', title: '物料排名', width: 80, unresize: true, sort: true,},
            {title: "物料编码", field: "materialCode"},
            //{title: "物料描述", field: "materialDesc"},
            {title: "订单总价值", field: "orderTotalPrice"},
            {
                title: "订单金额所占的百分比", field: "pricePercentage",
                formatter: function (value, row, index) {
                    var num = value * 100 + "%";
                    return num;
                }
            },
            {title: "订单总数量", field: "orderTotalNumber"},
            {
                title: "订单总数量所占的百分比", field: "ordersPercentage",
                formatter: function (value, row, index) {
                    var num = value * 100 + "%";
                    return num;
                }
            },
        ],
    );


    $(function () {
            // 初始化时间插件
            laydate.render({elem: '#beginDate'});
            laydate.render({elem: '#endDate'});
            initDictDataSel();//初始化所有字典数据
        }
    );

    //导出excel
    function Export() {
        let materialCode = itemBS.getSelectedRows("materialCode");
        var rowNo = itemBS.getSelectedRows("rowNo");
        if (materialCode.length < 1) {
            Dialog.errorMsg("请选择一行数据!!!");
            return;
        }
        window.location.href = ctxPath + "/materialSummary/export?materialCode=" + materialCode;
    }

</script>
</body>
</html>